package com.myhouse.common.utils.myquartz.factory;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;

/**
 * scheduler工厂（单例模式）
 * @author 章瑜亮
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class SchedulerFactory {
    private static Scheduler scheduler;

    public static Scheduler getInstance() {
        if (scheduler == null) {
            try {
                scheduler = new StdSchedulerFactory().getScheduler();
            } catch (SchedulerException e) {
                e.printStackTrace();
            }
        }
        return scheduler;
    }


}
